package com.wbhealth.ceshihello.controller;

import com.wbhealth.ceshihello.util.AddressUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by bee on 2022/8/11.
 */
@RequestMapping("/video")
@Slf4j
@RestController
public class HelloController {

    @GetMapping("/ip")
    public String hello() {
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            String ipAddress = AddressUtils.getIpAddress(request);
            log.info("hell2: {}",ipAddress);
            return ipAddress;
        }catch (Exception e){
            log.info("异常eee：{}",e.getMessage(),e);
        }
        return "异常了";
    }

    @GetMapping("/aaa")
    public String aaa() {

        return "123";
    }
}
